package view.component.weapon.flute
{
	import enums.main.UISize;
	
	import feathers.controls.Label;
	import feathers.data.ListCollection;
	
	import model.vo.weapon.FluteStaffVo;
	
	import view.component.BaseSCListView;
	import view.render.weapon.FluteStaffItem;
	
	
	/**
	 * 不同音色狩猎笛旋律列表界面基类
	 * @author £iang
	 * 
	 */	
	public class BaseStaffTypeView extends BaseSCListView
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 吹奏效果标题 */
		public var effectTitle:Label;
		/** 再次吹奏标题 */
		public var reEffectTitle:Label;
		/** 持续时间标题 */
		public var timeTitle:Label;
		/** 延续时间标题 */
		public var reTimeTitle:Label;
		/** 备注标题 */
		public var psTitle:Label;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initialize():void
		{ 
			_itemH = UISize.FLUTE_STAFF_ITEM_H * this.dpiScale;
			_listH = UISize.MAIN_H - 
				( UISize.MONSTER_TAB_AREA_H * 3 + 
					UISize.LIST_TITLE_H - 20) * this.dpiScale;
			_scrollerMaxPage = 2;
			_firstName = "旋律";
			super.initialize();
		}
		
		override protected function initializeOther():void
		{
			super.initializeOther();
			effectTitle = new Label();
			effectTitle.text = "吹奏效果";
			scollerContainer.addChild( effectTitle );
			
			timeTitle = new Label();
			timeTitle.text = "持续时间";
			scollerContainer.addChild( timeTitle );
			
			reEffectTitle = new Label();
			reEffectTitle.text = "再吹奏效果";
			scollerContainer.addChild( reEffectTitle );
			
			reTimeTitle = new Label();
			reTimeTitle.text = "延长时间";
			scollerContainer.addChild( reTimeTitle );
			
			psTitle = new Label();
			psTitle.text = "备注";
			scollerContainer.addChild( psTitle );
		}
		
		/**
		 * 绘制函数 
		 * 
		 */		
		override protected function draw():void
		{
			var labelY:Number = ( UISize.LIST_TITLE_H - 
				43 ) / 2 * this.dpiScale;
			var leftPadding:Number = UISize.TITLE_PADDING_LEFT * this.dpiScale;
			var firstLabelFullW:Number;
			
			firstTitle.y = labelY;
			firstTitle.x = leftPadding;
			firstLabelFullW = UISize.MAIN_W * 0.3;
			firstTitle.width = firstLabelFullW - leftPadding;
			
			scollerContainer.x = firstLabelFullW;
			scollerContainer.width = UISize.MAIN_W - firstLabelFullW;
			scollerContainer.height = UISize.LIST_TITLE_H;
			
			effectTitle.y = labelY;
			effectTitle.x = 0;
			effectTitle.width  = UISize.MAIN_W * 0.4;
			
			timeTitle.y = labelY;
			timeTitle.x = UISize.MAIN_W * 0.4;
			timeTitle.width  = UISize.MAIN_W * 0.3;
			
			reEffectTitle.y = labelY;
			reEffectTitle.x = UISize.MAIN_W * 0.7;
			reEffectTitle.width  = UISize.MAIN_W * 0.4;
			
			reTimeTitle.y = labelY;
			reTimeTitle.x = UISize.MAIN_W * 1.1;
			reTimeTitle.width  = UISize.MAIN_W * 0.3;
			
			psTitle.y = labelY;
			psTitle.x = UISize.MAIN_W * 1.4;
			psTitle.width  = UISize.MAIN_W * 0.7;
			
			var buttonY:Number = ( UISize.LIST_TITLE_H * this.dpiScale - leftButton.height ) / 2;
			
			leftButton.x = firstLabelFullW - leftButton.width;
			leftButton.y = buttonY;
			
			rightButton.x = UISize.MAIN_W - leftButton.width;
			rightButton.y = buttonY;
			
			list.y = UISize.LIST_TITLE_H * this.dpiScale;
		}
		
		/**
		 * 设置列表数据 
		 * @param dataVec 数据
		 * 
		 */		
		public function setListData( dataVec:Vector.<FluteStaffVo> ):void
		{
			var i:int;
			var len:int = dataVec.length;
			
			_listData = new ListCollection([]);
			
			for( i = 0; i < len; i++)
			{
				var item:FluteStaffItem = new FluteStaffItem();
				var tmpData:FluteStaffVo = dataVec[ i ] as FluteStaffVo;
				
				item.setData( tmpData );
				_listData.push( { item:item, itemData:tmpData } );
			}
			
			list.dataProvider = _listData;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构滚动条容器中的标签 
		 * 
		 */		
		protected override function disposeAnythingInContainer():void
		{
			disposeLabels( [
				"effect",
				"reEffect", "time",
				"reTime", "ps"
			] );
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function BaseStaffTypeView()
		{
			super();
		}
	}
}